import ddRequest from '@/service'
import { IAccount, ILoginResult } from '@/service/login/types'
import { IDataType } from '@/service/types'

enum LoginAPI {
  AccountLogin = '/login',
  LoginUserInfo = '/users/',
  UserMenus = '/role/' //用法:role/{id}/menu,id为角色id
}

export function accountLoginRequest(account: IAccount) {
  return ddRequest.post<IDataType<ILoginResult>>({
    url: LoginAPI.AccountLogin,
    data: account
  })
}

//根据用户id获取用户详情
export function requestUserInfoById(id: number) {
  return ddRequest.get<IDataType>({
    url: LoginAPI.LoginUserInfo + id
  })
}

export function requestUserMenusByRoleId(id: number) {
  return ddRequest.get<IDataType>({
    url: LoginAPI.UserMenus + id + '/menu'
  })
}
